package com.hymjweb.demo.hymj.basic_data_manage.xt_compay_login.mapper;

import com.hymjweb.demo.hymj.basic_data_manage.xt_company.bean.XtCompanyCachePojo;
import com.hymjweb.demo.hymj.basic_data_manage.xt_company.bean.XtCompanyPojo;
import com.hymjweb.demo.hymj.basic_data_manage.xt_company.mapper.XtCompanyMapper;
import com.hymjweb.demo.hymj.basic_data_manage.xt_compay_login.bean.XtCompanyLoginPojo;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.jdbc.SQL;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;


/**
 * @BelongsProject: demo
 * @BelongsPackage: com.hymjweb.demo.hymj.basic_data_manage.xt_compay_login.mapper
 * @Author: luoge
 * @CreateTime: 2021-10-27 16:44
 * @Description:
 */
@Mapper
@Component
public interface XtCompanyLoginMapper {

    class XtCompanyLoginProvider{

        public String findCacheAll() {
            return new SQL() {{
                SELECT("xcl.*");
                FROM("xt_company_login xcl");
            }}.toString();
        }


        public String findObjectById(String id) {
            return new SQL() {{
                SELECT("xcl.*");
                FROM("xt_company_login xcl");
                WHERE("xcl.id = #{id}");
            }}.toString();
        }


        public String insert(XtCompanyLoginPojo obj) {
            String sql= new SQL() {{
                INSERT_INTO("xt_company_login");
                VALUES("id","#{id}");
                VALUES("name","#{name}");
                VALUES("english_name","#{englishName}");
                VALUES("record_no","#{recordNo}");
                VALUES("copyright","#{copyright}");
                VALUES("validity","#{validity}");
            }}.toString();
            return sql;
        }

        public String update(XtCompanyLoginPojo obj) {
            String sql= new SQL() {{
                UPDATE("xt_company_login xcl");
                SET("xcl.name = #{name}");
                SET("xcl.english_name = #{englishName}");
                SET("xcl.record_no = #{recordNo}");
                SET("xcl.copyright = #{copyright}");
                SET("xcl.validity = #{validity}");
                WHERE("xcl.id=#{id}");
            }}.toString();
            return sql;
        }

        public String delete(String id) {
            String sql = new SQL() {{
                DELETE_FROM("xt_company_login");
                WHERE("id = #{id}");
            }}.toString();
            return sql;
        }
    }


    @Results(id="xtCompanyLoginMapId",value = {
            @Result(column = "id", property = "id"),
            @Result(column = "name", property = "name"),
            @Result(column = "english_name", property = "englishName"),
            @Result(column = "record_no", property = "recordNo"),
            @Result(column = "copyright", property = "copyright"),
            @Result(column = "validity", property = "validity")
    })
    @SelectProvider(type = XtCompanyLoginProvider.class, method = "findCacheAll")
    List<XtCompanyLoginPojo> findCacheAll();

    @ResultMap(value = "xtCompanyLoginMapId")
    @SelectProvider(type = XtCompanyLoginProvider.class, method = "findObjectById")
    XtCompanyLoginPojo findObjectById(@Param("id") String id);

    @InsertProvider(type = XtCompanyLoginProvider.class, method = "insert")
    @Options(keyProperty = "id")
    int insert(XtCompanyLoginPojo obj);


    @UpdateProvider(type = XtCompanyLoginProvider.class, method = "update")
    int update(XtCompanyLoginPojo obj);

    @DeleteProvider(type = XtCompanyLoginProvider.class, method = "delete")
    int delete(String id);



}
